package rwt.server.handlers.web;

import rwt.server.*;
import rwt.server.RailroadMessages.PowerOffMsg;
import rwt.server.RailroadMessages.PowerOnMsg;
import rwt.server.WebMessages.ChangePowerStatus;
import rwt.server.core.*;
import rwt.server.mtl.java.MessageTranslationLibrary.OnOffType;

public class ChangePowerStatusHandler extends MessageHandler<ChangePowerStatus>
{
	@Override
	public void handle(ChangePowerStatus message, IConnection source) throws Exception
	{
		BaseMessage msg = (message.onOffState == OnOffType.On) ? new PowerOnMsg() : new PowerOffMsg();
		RailServer.getController().write(msg);
	}
}
